package com.itheima;

import java.awt.*;

public class Monster {
    private int x, y;
    private final int width = 50;
    private final int height = 50;

    public Monster(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public void moveDown() {
        y += 2;
    }

    public void draw(Graphics g) {
        // 绘制怪兽
        g.setColor(Color.RED);
        g.fillOval(x, y, width, height);

        // 绘制怪兽眼睛
        g.setColor(Color.WHITE);
        g.fillOval(x + 10, y + 15, 10, 10);
        g.fillOval(x + 30, y + 15, 10, 10);

        // 绘制怪兽嘴巴
        g.setColor(Color.BLACK);
        g.fillOval(x + 15, y + 30, 20, 10);
    }

    public boolean collidesWith(Airplane airplane) {
        return x < airplane.getX() + 50 &&
                x + width > airplane.getX() &&
                y < airplane.getY() + 50 &&
                y + height > airplane.getY();
    }
}
